diff options
| author | Adam Soltys <[email protected]> | 2024-11-26 13:08:08 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-11-26 13:20:53 -0800 |
| commit | 0bf630c39fe290ea2718eab7a0759d978c736ef9 (patch) | |
| tree | a670c3ae954d5075c851126c2aca7a1a45d1b41d /src/routes/(app)/send/bitcoin/[address]/+layout.server.ts | |
| parent | 41ee0027e1767e4d116330bdee2e0456fd45f940 (diff) | |
| download | coinos-ui-0bf630c39fe290ea2718eab7a0759d978c736ef9.tar.gz coinos-ui-0bf630c39fe290ea2718eab7a0759d978c736ef9.zip | |
bip21 and socket fixes
Diffstat (limited to 'src/routes/(app)/send/bitcoin/[address]/+layout.server.ts')
| -rw-r--r-- | src/routes/(app)/send/bitcoin/[address]/+layout.server.ts | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts b/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts index 68191311..a321ec43 100644 --- a/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts +++ b/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts @@ -4,20 +4,22 @@ import { redirect } from "@sveltejs/kit"; export async function load({ cookies, params, parent }) { const { user } = await parent(); const aid = cookies.get("aid"); - const { address } = params; + const { address, amount } = params; const { balance } = await get(`/account/${aid}`, auth(cookies)); + let invoice; try { - const invoice = await get(`/invoice/${address}`); - - if (invoice) { - const recipient = await get(`/users/${invoice.uid}`); - if (recipient?.id !== user.id) - redirect(307, `/pay/${recipient.username}`); - } + invoice = await get(`/invoice/${address}`); } catch (e) { // invoice not found } + if (invoice) { + const recipient = await get(`/users/${invoice.uid}`); + let r = `/pay/${recipient.username}`; + if (amount) r += `/${amount}`; + if (recipient?.id !== user.id) redirect(307, r); + } + return { balance }; } |
